<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加材料</title>
</head>
<body>

<form class="layui-form" lay-filter="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <blockquote class="layui-elem-quote">基础信息</blockquote>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        材料名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入材料名称"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <text style="color:red;">支持jpg、png，大小不超过5M，图片尺寸建议 7:10比例</text>
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        材料图标</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="icon"
                             data-dir="xm_game/basic/content/icon"
                             data-accept="image"
                             data-type="ali-oss"
                             data-layVerify="required"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">
                    材料描述</label>
                <div class="layui-input-block" style="width: 60%">
                    <textarea placeholder="请输入材料描述" name="description" id="LAY_demo" lay-verify="content" ></textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">
                    材料补充描述</label>
                <div class="layui-input-block" style="width: 60%">
                    <textarea placeholder="请输入材料补充描述" name="append_description" id="LAY_demo2" lay-verify="content2" ></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    if (localStorage.getItem("staticDomain")) {
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    } else {
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    }
</script>
<script>
    layui.use(['laytp','layedit',"form"], function () {
        let game_id = facade.getUrlParam("game_id");
        var layedit = layui.layedit;
        let form = layui.form;
        layedit.set({
            uploadImage: {
                url: "/admin.common/editUpload"
                , type: ''//默认post
            },
            uploadVideo: {
                url: "/admin.common/editUpload"
                ,accept:"m3u8"
                , type: ''//默认post
            }
        })
       var index = layedit.build('LAY_demo', {
            tool: [
                'strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right', '|', 'image', 'video'
            ],
            height: 500,
        });
        var index2 = layedit.build('LAY_demo2', {
            tool: [
                'strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right', '|', 'image', 'video'
            ],
            height: 500,
        });
        form.verify({
            content: function (value) {
                return layedit.sync(index);
            },
            content2: function (value) {
                return layedit.sync(index2);
            },
        });
        layui.form.on('submit(add)', function (data) {
            var btnAnim = layui.button.load({elem: $(this)});
            facade.ajax({
                route: '/admin.basic.content/add?game_id='+game_id,
                data: data.field
            }).done(function (res) {
                if (res.code === 0) {
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                    parent.location.reload();
                }
                btnAnim.stop();
            }).fail(function () {
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>